//
//  UIViewController+WDShowAlertController.m
//  Zhihuijinfu
//
//  Created by 王笛 on 2016/11/29.
//  Copyright © 2016年 王笛. All rights reserved.
//

#import "UIViewController+WDShowAlertController.h"

@implementation UIViewController (WDShowAlertController)

- (void)showAlertWithMessage:(NSString *)message
{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *certain = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:nil];
    
    [alert addAction:certain];
    
    [self presentViewController:alert animated:YES completion:nil];
}

- (void)showAlertWithTitle:(NSString *)title Message:(NSString *)message leftStr:(NSString *)leftStr rightStr:(NSString *)rightStr leftBtnClick:(leftBlock)leftBlock rightClick:(rightBlock)rightBlock
{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    
    //左边
    UIAlertAction *certain  = [UIAlertAction actionWithTitle:leftStr style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        
        leftBlock();
    }];
    
    //右边
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:rightStr style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        rightBlock();
    }];
    
    [alert addAction:certain];
    [alert addAction:cancel];
    
    [self presentViewController:alert animated:YES completion:nil];
}

@end
